#!/bin/bash -n

( 

owner=$(./ttyowner);

cd support/ghtml; 

echo''

[[ $1 = remove ]] && {

    bash.report "Removing ghtml" rm -rfv /bin/ghtml;
    return;
    
} || {

	bash.report "Checking build dependencies: (webkitgtk-3.0 development package)" \
	"pkg-config --exists webkitgtk-3.0" || exit 1;

    su $owner && echo && bash.report "Installing ghtml" \
    cp -f -t /bin ghtml;
    
} <<<". bash-masters;
bash.report 'Compiling ghtml' make || exit 1;

bash.report 'Compacting ghtml' \
    strip --strip-unneeded ghtml || exit 1;
echo ''
bash.report 'Creating ghtml user lib directory' mkdir -p ~/bash-masters/ghtml/lib;
bash.report 'Copying lib files' cp -vt ~/bash-masters/ghtml/lib examples/sql/sql_files/sql.js;
echo ''
bash.report 'Installing user samples (~/bash-masters/ghtml)' 'mkdir -p ~/bash-masters/ghtml; cp -rf -t ~/bash-masters/ghtml examples';
bash.report 'Installing sample launchers' mv -t ~/bash-masters ~/bash-masters/ghtml/examples/*test;

";)

